<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no" />
    <title>会议同传</title>
    <link rel="stylesheet" href="../css/mui.min.css">
    <script src="../js/mui.min.js"></script>
    <!--App自定义的css-->
    <link rel="stylesheet" type="text/css" href="../css/app.css" />
    <script src="../js/jquery-3.6.0.min.js"></script>
    <link rel="stylesheet" href="../npl/css/vant.mini.css" />
    <link rel="stylesheet" href="../css/voice.css">
    <script src="../js/vue.js"></script>
    <script src="../js/vconsole.min.js"></script>
    <script src="../js/flexible.js"></script>
    <script src="../js/clipboard.js"></script>
    <script src="../npl/js/vant.mini.js"></script>
    <script src="../js/sm3.js"></script>
    <script src="../js/sm2.js"></script>
    <script src="./text.js" type="text/javascript"></script>
</head>
<style>
    body {
        margin: 0;
        padding: 0;
    }

    #app {
        background-color: #fff;
    }

    .box {
        width: 100%;
        height: 100%;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .form-box {
        display: flex;
        padding: 10px 10px 8px;
    }

    .van-cell--required::before {
        left: .26rem;
    }

    .form-box .van-cell {
        border-radius: 7px;
        align-items: center;
        padding: 0 .4rem;

    }

    .van-cell {
        font-weight: 500;
        font-size: 15px !important;

    }

    .form-box .van-cell.van-field--min-height {
        /* padding: 10px 10px 0; */
    }

    .van-cell__value,
    .van-field__body {
        width: 100%;
        height: 100%;
    }

    .form-box .van-field--disabled {

        color: #646566;
    }

    .form-box input[type=text] {
        border: none;
        margin-bottom: 0;
        padding: 0;
    }

    .van-nav-bar {
        /* background: none !important;; */
    }

    .wrapper {
        display: flex;
        flex-direction: column;
        flex: 1;
    }

    .van-field__control:disabled {
        width: 100%;
        height: 100%;
        -webkit-text-fill-color: #323233;
        color: #323233;
    }

    .text_b {
        display: flex;
        height: 1rem;
        width: 100%;
        background-color: #fff;
        padding: 0 20px;
        align-items: center;
        justify-content: space-between;
    }

    .text_b_imgbox {
        /* width: ; */
        display: flex;
    }

    .text_b_imgbox p {
        width: .8rem;
        height: .8rem;
    }

    .text_b_imgbox p:nth-child(1) {
        margin-right: 15px;
    }

    .text_b_imgbox p img {
        width: 100%;
        height: 100%;
    }

    .van-button--primary {
        /* height: .7rem !important; */
        background-color: #62cccc !important;
        border: none !important;
    }

    .ldBtn {
        display: flex;
        justify-content: space-between;
        padding: 0 20px 10px;
    }
    .ldBtn_box {
        display: flex;
        /* justify-content: space-between; */
        /* padding: 0 20px 10px; */
    }

    .ldBtn_img {
        width: 1rem;
        height: 1rem;
    }

    .ldBtn_img img {
        width: 100%;
        height: 100%;
    }

    .popTitle {
        display: flex;
        justify-content: center;
        align-items: center;
        height: 1rem;
        padding: .6rem 0 0;
        color: #000;
        font-size: 19px;
        margin-bottom: .7rem;
        font-weight: bold;

    }

    .vanPop {
        padding: 0 10px 10px
    }

    .van-radio__icon--checked .van-icon {
        background-color: #fff !important;
        border-color: #fff !important;
        color: #19a97b;
    }

    .van-cell--clickable:active {
        background-color: #fff !important;
    }

    .van-icon-success:before {
        background-color: #fff !important;
        border-color: #fff !important;
    }

    .van-radio__icon .van-icon {
        border: none !important;
    }

    .van-nav-bar .van-icon {
        color: #000;
        font-size: 12px;
    }

    .jiantou {
        font-size: 25px;
    }

    .box_from {
        flex: 1;
        background-color: #F3F6FF;
        display: flex;
        flex-direction: column;
    }

    .btn_l_img {
        margin: 0 .2rem;
        width: 0.96rem;
        height: 0.56rem;
    }

    .btn_l_img img {
        width: 100%;
        height: 100%;
    }

    .mui-toast-container {
        top: 50%
    }
</style>
</head>

<body>
    <div class="box" id="app">
        <div class="is-loading">
            <div class="is-loading">
                <div class="curtain" id="curtain">
                    <div class="loadingBgc">
                        <div class="loader"></div>
                    </div>
                </div>
            </div>
        </div>

        <div class="header_tit">
            <van-nav-bar left-arrow>
                <template #left>
                    <div class="back_l" @click="home"><img src="../image/left.png" alt=""></div>
                </template>
                <template #title>
                    <!-- @click="popShow=true" -->
                    <div style="display:inline;" v-html="langAct">
                    </div>
                    <!-- <div style="display:inline;">
                        <van-icon name="arrow-down" />
                    </div> -->
                </template>
                <!-- <template #right>
                    <div class="btn_l_img" @click=""><img src="../image/lu_youx.png" alt=""></div>
                </template> -->
            </van-nav-bar>
        </div>
        <van-popup style="min-height: 4rem;" :close-on-click-overlay="false" v-model="showPop">
            <van-form>
                <div style="text-align: center;font-size: 18px;font-weight:bold;">标题</div>
                <van-field v-model="inputText" class="edit_title_input" placeholder="请输入标题" maxlength="100" />
            </van-form>
            <div class="form_btn">
                <van-button type="default" round @click="del">取消</van-button>
                <van-button type="primary" color="#13C09B" round @click="confirm">确定</van-button>
            </div>
        </van-popup>
        <!-- 后续改成'54%' -->
        <!-- <van-popup :close-on-click-overlay="false" class="vanPop" v-model="popShow" closeable position="bottom"
            :style="{height: '29%',borderRadius:'5% 5% 0 0',left:0,bottom:0}">
            <div class="popTitle">
                切换语言
            </div>
            <van-radio-group v-model="radio">
                <van-cell-group>
                    <van-cell v-for="(item,index) in langList" :title="item.title" clickable @click="radio = item.id">
                        <template #right-icon>
                            <van-radio :name="item.id" />
                        </template>
                    </van-cell>
                </van-cell-group>
            </van-radio-group>
        </van-popup> -->
        <div class="wrapper">
            <div class="form-box">
                <van-field  @contextmenu="handleContextMenu"    v-model="content" readonly  @touchstart.prevent  type="textarea" rows="12" ref="field1" @click="demo1" disabled
                    show-word-limit id='output_box' style="background:none;user-select: none;" />
            </div>
            <div class="box_from">
                <div class="form-box" style="flex:1">
                    <van-field readonly  @touchstart.prevent
                    @contextmenu.prevent ref="field1" id='output_box_web'  v-model="content1"
                        type="textarea" style="background:none;user-select: none;width:100%;height:100%" disabled show-word-limit />
                </div>
                <div class="ldBtn">
                   <div></div>
                   <div class="ldBtn_box">
                    <div class="ldBtn_img">
                        <img @click="stopRecorder" v-if='checkClick == 0' src="../image/zt.png" alt="">
                        <img @click="getMeToken" v-else src="../image/ld1.png" alt="">
                    </div>
                    <div class="ldBtn_img" style="margin-left: 15px;">
                        <img @click="saveBtn" src="../image/bc.png" alt="">
                    </div>
                   </div>
                </div>
            </div>
        </div>
    </div>
</body>
<script>
    new Vue({
        el: '#app',
        data() {
            let voicelist = [];
            return {
                content: '',
                content1: "",
                checkClick: 0,
                voiceTxt: {
                    old: '',
                    ind: null
                },
                inputDom: null,
                showPop: false,
                inputDomweb: null,
                autoScroll: true,
                inputText: '',
                MODEL_CODE: '1888',
                CAPACITY_CODE: '010115',
                LANG: 'zh',
                WS_URL: '',
                myWebsocket: null,
                translateWS_URL: '',
                count: 0,
                type: "cnen",
                popShow: false,
                changeID: this.generateUUID(),
                radio: "2",
                langAct: '英 <span class="jiantou">→</span> 中',
                langList: [{
                        id: "1",
                        type: "cnen",
                        title: '中译英 （随身译）',
                        content: '中 <span class="jiantou">→</span> 英 '

                    },
                    {
                        id: "2",
                        type: 'encn',
                        title: '英译中 （随身译）',
                        content: '英 <span class="jiantou">→</span> 中 '

                    },
                    // {
                    //     id: "3",
                    //     title: '中译日 （随身译）',
                    //     content: '中 <span class="jiantou">→</span> 日 '

                    // },
                    // {
                    //     id: "4",
                    //     title: '日译中 （随身译）',
                    //     content: '日 <span class="jiantou">→</span> 中 '

                    // },
                    // {
                    //     id: "5",
                    //     title: '中译韩 （随身译）',
                    //     content: '中 <span class="jiantou">→</span> 韩 '

                    // },
                    // {
                    //     id: "6",
                    //     title: '韩译中 （随身译）',
                    //     content: '韩 <span class="jiantou">→</span> 中 '

                    // },
                ]
            }
        },
        watch: {
            radio: {
                handler(t) {
                    this.langList.find((item) => {
                        if (item.id == t) {
                            this.type = item.type
                            this.langAct = item.content
                        }
                        this.popShow = false
                    })
                },
                immediate: true
            },
        },
        created() {
            $.getScript("../js/jweixin-sgccigw-1.0.0.js" /*"js/jweixin-1.0.0.js"*/ , () => {
                let jsApiList = [];
                let _this = this
                wx.ready(() => {
                    _this.getMeToken()
                    // let timestamps = new Date().getTime() + ""
                    // let AuthenticationSession = sessionStorage.getItem("Authentication");
                    // let Sign = sm3(timestamp + "&" + "encn");
                    // _this.translateWS_URL =
                    //     `ws://172.20.10.2:18080/tjAiAssistant/websocket?Authentication=${AuthenticationSession}&timestamp=${timestamp}&type=${_this.type}&sign=${Sign}`
                    // console.log(_this.translateWS_URL, "后端wensocke")
                    // _this.myWebsocket = new WebSocket(_this.translateWS_URL);
                    // // 连接发生错误的回调方法
                    // _this.myWebsocket.onerror = (error) => {
                    //     console.log("error", error)
                    //     _this.onError(error);
                    // };
                    // //连接成功建立的回调方法
                    // _this.myWebsocket.onopen = (event) => {
                    //     console.log("跟后端的wensocket建立成功")
                    // };

                    // _this.myWebsocket.onmessage = (evt) => {
                    //     _this.onMessageT(evt);
                    // };
                    // //连接关闭的回调方法
                    // _this.myWebsocket.onclose = (evt) => {
                    //     console.log("evt", evt)
                    // };
                    wx.onHistoryBack(() => {
                        _this.home()
                        return false
                    })
                });
                jsApiList = [
                    'startRecord',
                    'stopRecord',
                    'onVoiceRecordEnd',
                    'translateVoice',
                    'onHistoryBack',
                    'startRecordVoiceBuffer',
                    'ext_AudioRecorder_Start',
                    'ext_AudioRecorder_Stop',
                    'onRecordBufferReceived',
                    'multiWindows_subscribe',
                    'stopRecord',
                    "onHistoryBack"
                ];
                wx.config({
                    beta: true,
                    debug: false,
                    appId: "ww4d11a39991ebffdc",
                    timestamp: '1639582452',
                    nonceStr: "AMQGnmTMzhJetshY",
                    signature: 'fb9f560a9b4824f7db3525926994010de74ea055',
                    jsApiList: jsApiList
                });
            });
        },
        mounted() {
            this.$nextTick(() => {
                this.inputDom = document.getElementById("output_box")
                this.inputDomweb = document.getElementById("output_box_web")
                // this.testMsg()
            })
        },
        methods: {
            handleContextMenu(event) {
      const menu = event.target.ownerDocument.defaultView.getSelection().toString();
      if (menu === '') {
        event.preventDefault();
      }
    },
            // 测试数据
            // testMsg () {
            // 	const morkData = `天通苑人有人与人如意天通苑有人与人人如意天通苑有人与人  如意天通苑人有人与人如意苑人有人与人如意天通苑有人与人人如意天通苑有人与人  如意天通苑人有人与人如意苑人有人与人如意天通苑有人与人人如意天通苑有人与人  如意天通苑人有人与人如意天苑人有人与人如意天通苑有人与人人如意天通苑有人与人  如意天通苑人有人与人如意苑人有人与人如意天通苑有人与人人如意天通苑有人与人  如意天通苑人有人与人如意苑人有人与人如意天通苑有人与人人如意天通苑有人与人  如意天通苑人有人与人如意天苑人有人与人如意天通苑有人与人人如意天通苑有人与人  如意天通苑人`
            // 	morkData.split('').forEach((item,index) =>{
            // 		const word = morkData.slice(0,index + 1)
            // 		const completed = index === morkData.length - 1 
            // 		setTimeout(()=>{
            //             this.doSend(word)
            //             console.log(word,78787)
            // 			// this.onMessageT({
            // 			// 	data:JSON.stringify({
            // 			// 		word: word,
            //             //         code:200,
            // 			// 		completed: completed
            // 			// 	})
            // 			// })
            // 		}, (index+1)*1000 ) 
            // 	})
            // },
            saveBtn() {
                if (this.checkClick == 0) {
                    mui.toast('请先关闭麦克风', {
                        duration: 1000,
                        type: 'div'
                    })
                    return
                }
                this.showPop = true
              
                this.inputText =this.getTime() + "会议翻译"
            },
            getTime() {
                var currentDate = new Date();
                var month = currentDate.getMonth() + 1; // 月份是从0开始计数的，所以要加1
                var day = currentDate.getDate();
                console.log(`当前月份是${month}，当前日期是${day}`);
                return `${month}月` + `${day}日`
            },
            del() {
                this.showPop = false;
            },
            home() {
                $(location).attr("href", "translationPage.html");
            },
            confirm() {
                if (!this.inputText || this.inputText.split(" ").join("").length == 0) {
                    mui.toast('标题不能为空', {
                        duration: 'long',
                        type: 'div'
                    })
                    return
                }
                this.showPop = false;
                this.complete()
            },
            complete() {
                // $(".curtain").css("display", "block");
                const userId = sessionStorage.getItem("userId");
                const timestamp = new Date().getTime() + ""
                const orgId = sessionStorage.getItem("unitId")
                if (sessionStorage.getItem("iscp_port")) {
                    iscp_port = sessionStorage.getItem("iscp_port");
                } else {
                    iscp_port = ""
                }
                let data = {
                    "messageTitle": this.inputText,
                    "dataText": this.content,
                    "id":this.changeID,
                    "resultText": this.content1,
                    "userId": userId,
                    "orgId": orgId,
                    "timestamp": timestamp,
                };
                let AuthenticationSession = sessionStorage.getItem("Authentication");
                data = JSON.stringify(data)
                let sign = sm3(data);
                $.ajax({
                    url: localUrlLink + iscp_port + "/tjAiAssistant/translation/save",
                    type: "post",
                    async: false, //是否同步，false表示同步请求
                    dataType: "json",
                    data: data,
                    headers: {
                        "Content-Type": "application/json;charset=UTF-8",
                        Authentication: AuthenticationSession,
                        sign: sign
                    },
                    success: (res, txt, xhr) => {
                        $(".curtain").css("display", "none");
                        if (sm3(res.resultValueStr) == xhr.getResponseHeader("sign")) {
                            let Authentication = xhr.getResponseHeader("Authentication")
                            if (res.code == 200) {
                                if (Authentication) {
                                    sessionStorage.setItem("Authentication", Authentication);
                                    mui.toast('保存成功', {
                                        duration: 'long',
                                        type: 'div'
                                    })
                                    setTimeout(() => {
                                        $(location).attr("href", "translationPage.html");
                                    }, 1000)
                                }
                            } else {
                                mui.toast(res.resultValue, {
                                    duration: 'long',
                                    type: 'div'
                                })
                            }
                        } else {
                            mui.toast('完整性校验失败', {
                                duration: 'long',
                                type: 'div'
                            })
                        }
                    },
                    error: (e) => {
                        $(".curtain").css("display", "none");
                        mui.toast('请求异常,请稍后再试', {
                            duration: 1000,
                            type: 'div'
                        })
                    },
                });
            },
            starPlay() {
                this.ldBtn = !this.ldBtn
            },
            stopPlay() {
                this.ldBtn = !this.ldBtn
            },
            getMeToken() {
                let _that = this
                _that.voiceTxt.ind = null
                var iscp_port = ''
                if (sessionStorage.getItem("iscp_port")) {
                    iscp_port = sessionStorage.getItem("iscp_port");
                }
                userId = sessionStorage.getItem("userId");
                let AuthenticationSession = sessionStorage.getItem("Authentication");
                const timestamp = new Date().getTime() + ""
                let data = {
                    "userId": userId,
                    "timestamp": timestamp,
                }
                const datas = JSON.stringify(data)
                let sign = sm3(datas);
                $.ajax({
                    url: localUrlLink + iscp_port + "/tjAiAssistant/soundRecording/thirdparty",
                    type: "post",
                    async: false, //是否同步，false表示同步请求
                    dataType: "json",
                    data: datas,
                    headers: {
                        "Content-Type": "application/json;charset=UTF-8",
                        sign: sign,
                        Authentication: AuthenticationSession,
                    },
                    success: (res, txt, xhr) => {
                        if (sm3(res.resultValueStr) == xhr.getResponseHeader("sign")) {
                            let Authentication = xhr.getResponseHeader("Authentication")
                            if (res.code == 200) {
                                if (Authentication) {
                                    sessionStorage.setItem("Authentication", Authentication);
                                    _that.WS_URL =
                                        `ws://127.0.0.1:${iscp_port}/websocket/asr/i?token=${res.resultValue}&capacityCode=${_that.CAPACITY_CODE}&language=${_that.LANG}&code=${_that.MODEL_CODE}&sessionId=${_that.changeID}`
                                    if (_that.count < 1) {
                                        wx.invoke("multiWindows_subscribe", {
                                            channelId: _that.changeID
                                        }, function (res) {
                                            console.log(res.data.message, "信息")
                                            if (res.data.method == "onMessage String" && res
                                                .data.channelId == _that.changeID) {
                                                _that.onMessage(res)
                                            } else if (res.data.method ==
                                                'onReconnectFinishAndDisconn') {
                                                //重连失败处理
                                                _that.stopVB()
                                            }
                                        });
                                        // let timestamps = new Date().getTime() + ""
                                        let Sign = sm3(timestamp + "&" + _that.type);
                                        _that.translateWS_URL =
                                            `ws://127.0.0.1:${iscp_port}/tjAiAssistant/websocket?Authentication=${Authentication}&timestamp=${timestamp}&type=${_that.type}&sign=${Sign}`
                                        console.log(_that.translateWS_URL, "后端wensocke")
                                        _that.myWebsocket = new WebSocket(_that.translateWS_URL);
                                        // 连接发生错误的回调方法
                                        _that.myWebsocket.onerror = (error) => {
                                            console.log("error", error)
                                            _that.onError(error);
                                        };
                                        //连接成功建立的回调方法
                                        _that.myWebsocket.onopen = (event) => {
                                            console.log("跟后端的wensocket建立成功")
                                        };

                                        _that.myWebsocket.onmessage = (evt) => {
                                            _that.onMessageT(evt);
                                        };
                                        //连接关闭的回调方法
                                        _that.myWebsocket.onclose = (evt) => {
                                            console.log("evt", evt)
                                        };
                                    }

                                    _that.count++
                                    //1.开始录音
                                    wx.invoke("ext_AudioRecorder_Start", {
                                            data: {
                                                channelId: _that.changeID,
                                                socketUrl: _that.WS_URL
                                            }
                                        },
                                        function (res) {
                                            if (res.err_msg === 'ext_AudioRecorder_Start:ok') {
                                                //成功处理
                                                _that.checkClick = 0
                                            }

                                            if (res.err_msg ===
                                                'ext_AudioRecorder_Start:fail') {
                                                //失败处理
                                            }
                                            if (res.err_msg ===
                                                'ext_AudioRecorder_Start:cancel') {
                                                //取消处理
                                            }
                                            if (res.err_msg ===
                                                'ext_AudioRecorder_Start:not_support ') {}
                                        })
                                }
                            } else {
                                mui.toast(res.resultValue, {
                                    duration: 'long',
                                    type: 'div'
                                })
                            }
                        }
                    },
                    error: (e) => {
                        _that.initLoading = false
                        mui.toast('请求异常,请稍后再试', {
                            duration: 1000,
                            type: 'div'
                        })
                    },
                })
            },
            onError(evt) {
                throw new Error('websocket连接失败' + evt.data);
            },
            doSend(message) {
                this.myWebsocket.readyState === 1 && this.myWebsocket.send(message);
            },
            onMessageT(evt) {
                // console.log(evt.data, 7777)
                try {
                    const data = JSON.parse(evt.data);
                    console.log(data.payload, " data.header2")
                    console.log(data.payload.result, " data.header3")
                    this.content1 += data.payload.result[0]
                    var allowWeb = false
                    console.log(this.inputDomweb.clientHeight, this.inputDomweb.scrollTop, this.inputDomweb
                        .scrollHeight, 787878)
                    if (this.inputDomweb.clientHeight * 4 / 3 + this.inputDomweb.scrollTop > this
                        .inputDomweb
                        .scrollHeight) {
                        allowWeb = true
                    }
                    if (allowWeb) {
                        setTimeout(() => {
                            this.inputDomweb.scrollTop = this.inputDomweb.scrollHeight
                        })
                    }
                } catch (error) {
                    throw new Error('解析错误!' + error);
                }
            },
            onMessage(evt) {
                try {
                    // const data = JSON.parse(evt.data);
                    const data = JSON.parse(evt.data.message);
                    // console.log(evt.data,"内容")
                    if (data.code == 200) {
                        if (this.voiceTxt.ind == null) {
                            this.voiceTxt.ind = this.content.length
                            // this.voiceTxt.ind = this.inputDom.selectionStart
                            this.voiceTxt.old = ''
                        }
                        var allow = false
                        console.log(this.inputDom.clientHeight, this.inputDom.scrollTop, this.inputDom
                            .scrollHeight, 787878)
                        if (this.inputDom.clientHeight * 4 / 3 + this.inputDom.scrollTop > this.inputDom
                            .scrollHeight) {
                            allow = true
                        }
                        // 这一行是赋值的
                        data.word = data.word.replace(/[|]/g, '')
                        // data.word = data.word.replace(/[|]/g, '\n')
                        // data.word = data.word.replace(/[\n]/g, '\n\n')
                        this.insertContent(data.word)
                        if (allow && this.autoScroll) {
                            setTimeout(() => {
                                this.inputDom.scrollTop = this.inputDom.scrollHeight
                            })
                        }
                        if (data.completed == true) {
                            this.doSend(data.word);
                            this.voiceTxt.ind += data.word.length
                            this.voiceTxt.old = ''
                            this.inputDom.setSelectionRange(this.voiceTxt.ind, this.voiceTxt.ind)
                            setTimeout(() => {
                                this.inputDom.setSelectionRange(this.voiceTxt.ind, this.voiceTxt
                                    .ind)
                            });
                        }
                    } else if (data.code == 'E000004') {
                        mui.toast("当前已达到最大并发量限制,请稍后再试", {
                            duration: 'long',
                            type: 'div'
                        })
                        this.stopRecorder()
                    } else {
                        mui.toast(data.code + "语音服务异常", {
                            duration: 'long',
                            type: 'div'
                        })
                        this.stopRecorder()
                    }
                } catch (error) {
                    throw new Error('解析错误!' + error);
                }
            },
            insertContent(txt) {
                const content = this.content
                const startIndex = this.voiceTxt.ind
                const delLength = this.voiceTxt.old.length
                this.content = this.insertTxt(content, startIndex, txt, delLength)
                this.voiceTxt.old = txt
                this.$nextTick(() => {
                    this.inputDom.setSelectionRange(this.voiceTxt.ind + txt.length, this
                        .voiceTxt
                        .ind + txt.length)
                })
            },
            insertTxt(content, index, txt, del) {
                let arr = content.split('')
                arr.splice(index, del, txt)
                return arr.join('')
            },
            stopRecorder(num) {
                let _this = this
                wx.invoke("ext_AudioRecorder_Stop", {
                        data: {}
                    },
                    function (res) {
                        console.log(res, "返回值")
                        if (res.err_msg === 'ext_AudioRecorder_Stop:ok') {
                            _this.stopVB(num)
                            wx.stopRecordVoiceBuffer({});
                            _this.checkClick = 1
                            _this.count = 0
                            _this.myWebsocket.close();
                        }
                        if (res.err_msg === 'ext_AudioRecorder_Stop:fail') {
                            //失败处理
                            console.log(res);
                        }
                        if (res.err_msg === 'ext_AudioRecorder_Stop:cancel') {
                            //取消处理
                            console.log(res);
                        }
                        if (res.err_msg === 'ext_AudioRecorder_Stop:not_support ') {
                            _this.stopVB(num)
                            wx.stopRecordVoiceBuffer({});

                        }
                    })
            },
            stopVB(num) {


            },
            generateUUID() {
                var d = new Date().getTime(); //Timestamp
                var d2 = (performance && performance.now && (performance.now() * 1000)) ||
                    0; //Time in microseconds since page-load or 0 if unsupported
                return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
                    var r = Math.random() * 16; //random number between 0 and 16
                    if (d > 0) { //Use timestamp until depleted
                        r = (d + r) % 16 | 0;
                        d = Math.floor(d / 16);
                    } else { //Use microseconds since page-load if supported
                        r = (d2 + r) % 16 | 0;
                        d2 = Math.floor(d2 / 16);
                    }
                    return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
                });
            },
            demo1() {
                console.log(999)
                // 判断光标是点击的0位还是默认直接说话
                // this.$refs.field1.focus();
                // var $input1 = document.getElementById("clipboardContent");
                // if ($input1.selectionStart == 0) {
                //     this.isFlagStartTrue = true
                // }
            },
        }
    })
</script>

</html>